package com.lqzs.businessmanager.ui.main.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.lqzs.businessmanager.R;
import com.lqzs.businessmanager.bean.ReplyInfo;
import com.lqzs.businessmanager.bean.response.LoginShopResponse;

public class EditCommentActivity extends AppCompatActivity {

    EditText edit_comment_content;
    TextView edit_user_comment;
    TextView edit_comment_username;
    TextView editactivity_save;

    TextView edit_activity_title;

    TextView edit_ativity_plantform_name;
    TextView detail_log_out;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_edit_comment);
        ReplyInfo replyInfo = (ReplyInfo) getIntent().getSerializableExtra("reply_item");
        int position = getIntent().getIntExtra("position",-1);
//edit_user_comment    edit_comment_username
        edit_comment_content=findViewById(R.id.edit_comment_content);
        edit_user_comment=findViewById(R.id.edit_user_comment);
        edit_comment_username=findViewById(R.id.edit_comment_username);
        editactivity_save=findViewById(R.id.editactivity_save);
        edit_activity_title=findViewById(R.id.edit_activity_title);
        edit_ativity_plantform_name=findViewById(R.id.edit_ativity_plantform_name);
        detail_log_out=findViewById(R.id.detail_log_out);

        edit_activity_title.setText(getIntent().getStringExtra("title"));
        edit_ativity_plantform_name.setText(getIntent().getStringExtra("address"));

        edit_comment_content.setText(replyInfo.getReplyContent());
        edit_user_comment.setText(replyInfo.getReviewerInfos());
        edit_comment_username.setText(replyInfo.getReviewer());

        edit_comment_content.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                replyInfo.setReplyContent(charSequence.toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });


        editactivity_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.putExtra("obj",replyInfo);
                intent.putExtra("position",position);
                setResult(RESULT_OK, intent);
                finish();
            }
        });



        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        detail_log_out.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditCommentActivity.this.finish();
            }
        });
    }

}